
Ext.define('Tg.tx.KEImg', {
    extend: 'Ext.form.field.Trigger',
    alias: ['widget.keimg'],
    alternateClassName: 'Ext.form.KEImg',
	urlType:'domain',
	editable:false,
    KEConfig: {},
    initComponent: function () {
        var me = this;
        me.callParent(arguments);
    },
    onTriggerClick: function () {
        var me = this;
		var _UidKey = me.uid
		if(!_UidKey){
			_UidKey = _USER['id'];
		}
		if(!_UidKey){
			_UidKey = 'sys';
		}
		var uJson = _PATH['site'] + '/admin/Files/upload/uid/'+_UidKey;
		var fJson = _PATH['site'] + '/admin/Files/filemanager/uid/'+_UidKey;
		KEditor = KindEditor.editor(Ext.apply(me.KEConfig, {
			urlType:me.urlType?me.urlType:'domain',
			filePostName:me.filePostName?me.filePostName:'files',
			extraFileUploadParams: {
				file_name: me.filePostName?me.filePostName:'files',
			},
			uploadJson : me.uploadJson?me.uploadJson:uJson,
			fileManagerJson : me.fileManagerJson?me.fileManagerJson:fJson,
			allowFileManager : true
		}));
		KEditor.loadPlugin('image', function() {
			KEditor.plugin.imageDialog({
				imageUrl : me.getValue(),
				clickFn : function(url, title, width, height, border, align) {
					if(me.urlType=='domain'){
						url = url.replace(_PATH['reg'], _PATH['site']);
					}
					url = url.replace(/\\/g, "\/");
					me.setValue(url);
					KEditor.hideDialog();
				}
			});
		});
    }
});